package com.bawei.module_home.mvp;

import android.util.Log;

import com.bawei.library_base.mvp.p.BasePresenter;
import com.bawei.library_base.utils.LogUtils;
import com.blankj.utilcode.util.ToastUtils;

import org.jetbrains.annotations.NotNull;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * @author : zhiyu
 * @date : 2021/12/13
 * @content :
 */
public class GoodsPresenter extends BasePresenter<GoodsContract.GoodsModel,GoodsContract.GoodsView> {

    public GoodsPresenter(GoodsContract.GoodsModel mModel, GoodsContract.GoodsView mView) {
        super(mModel, mView);
    }

    public void getGoods(String keyword,String type,int pageno,int pagesize){

        Log.i("wang", "getGoods: ");
      mModel.initModel(new Observer<Goods>() {
          @Override
          public void onSubscribe(@NotNull Disposable d) {
              Log.i("ons", "onNext: "+d.isDisposed());
              Log.i("wang", "onSubscribe");
          }

          @Override
          public void onNext(@NotNull Goods goods) {

              Log.i("wang", "onNext"+goods.toString());
                mView.initAdapter(goods.getData());
//                ToastUtils.showShort("lilili");
//              if(goods.getData()==null){
//                  ToastUtils.showShort("null");
//              }
//             ToastUtils.showShort(goods.getData().toString());

          }

          @Override
          public void onError(@NotNull Throwable e) {
              Log.i("wang", "onError"+e.getMessage());
          }

          @Override
          public void onComplete() {
              Log.i("wang", "onComplete");
          }
      },keyword,type,pageno,pagesize);
    }
}
